package cn.edu.xmu.restfuldemo.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;

@Data
@ApiModel(description = "订单明细视图对象")
public class OrderItemVo {
    @NotBlank(message="SKUID不能为空")
    @ApiModelProperty(value = "商品SKUID")
    private Integer skuId;

    @ApiModelProperty(value = "数量")
    private Integer quantity;

    @ApiModelProperty(value = "优惠活动ID")
    private Integer couponActId;

    /**
     * 由Vo对象创建OrderItem对象
     * @return OrderItem对象
     */
    public OrderItem createOrderItem(){
        OrderItem orderItem = new OrderItem();
        orderItem.setCouponActivityId(this.couponActId);
        orderItem.setQuantity(this.quantity);
        orderItem.setGoodsSkuId(this.getSkuId());
        return orderItem;
    }
}
